//
//  ItemViewController.m
//  XML
//
//  Created by Dang Duc Nam on 5/22/09.
//  Copyright 2009 Unitech. All rights reserved.
//

#import "ItemViewController.h"
#import "ItemWebViewController.h"
#import "eBayItem.h"


@implementation ItemViewController
@synthesize item;
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
	self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]
											   initWithBarButtonSystemItem:UIBarButtonSystemItemPlay
											   target:self action:@selector(goLive:)] autorelease];
	
	lblTitle.text = item.title;
	lblPrice.text = [NSString stringWithFormat:@"%@ %@",item.shippingCostSummary.ShippingCurrency,item.price];
	imageView.image = item.image;
	lblID.text = item.itemID;
	lblShippingCost.text = [NSString stringWithFormat:@"%@ %@",item.shippingCostSummary.ShippingCurrency,item.shippingCostSummary.ShippingServiceCost];
	lblShippingType.text = item.shippingCostSummary.ShippingType;
	lblStatus.text = item.status;
	lblTimeLeft.text = item.timeleft;
	lblEndTime.text = item.endtime;
	lblBidCount.text = item.bidcount;
	txtCategory.text = item.category;
    [super viewDidLoad];
}

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}

- (void)goLive:(id)sender {
	NSLog(@"Go Clicked");
	if(webViewer == nil)
		webViewer = [[ItemWebViewController alloc] initWithNibName:@"ItemWebView" bundle:[NSBundle mainBundle]];
	
	webViewer.itemID = item.itemID;
	
	[self.navigationController pushViewController:webViewer animated:YES];
	
}

- (void)dealloc {
    [super dealloc];
}


@end
